/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/
/*
This files contains definitions of types used in the context of HW assignment 1,
and special constants and conversion functions related to these types. 

Created by Amir Balva for the course "Introduction To Systems Programming", 
School of Electrical Engineering, Tel-Aviv University. winter 2014.
*/
/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/

#ifndef HW1_TYPES_H
#define HW1_TYPES_H

#include <stdlib.h> /* for atoi(), atof() */

#define MAX_ADDRESS_LENGTH 40
#define MAX_SUBJECT_LENGTH 50
#define MAX_CONTENT_LENGTH 350

typedef enum { F = 0, T = 1 } BOOL; //Boolean, False and True


typedef enum { 
    MARK_AS_READ,
    MARK_IMPORTANT_EMAIL,
    UNMARK_IMPORTANT_EMAIL,
    CREATE_EMAIL,
    DELETE_EMAIL,
	DOWNLOAD_EMAILS,
	CLOSE_PROGRAM,
	GET_EMAILS_TO_UI,
	PRINT_EMAILS_BRIEF,
	PRINT_EMAILS_FULL,
	GET_EMAILS_HIGH_TO_LOW,
	GET_EMAILS_LOW_TO_HIGH,
	GET_EMAILS_BY_WORD_SEARCH
    } 
Operation; //The operations are covered in details in excercise page


typedef char EmailAddress[MAX_ADDRESS_LENGTH];

typedef char EmailSubject[MAX_SUBJECT_LENGTH];

typedef char EmailContent [MAX_CONTENT_LENGTH];

typedef int EmailID, EmailDate, EmailHour;
/*
* This struct represents a single Email. The fields are as follows:
* Email ID - an integer that unique to each email
* EmailAddress recipient - the email address of the recipient
* EmailAddress recipient - the email address of the sender
* EmailDate date - the date which the mail was sent. Format: yyyymmdd
* EmailHour hour - the hour which the mail was sent. Format: hhmmss
* EmailSubject subject - the subject of the email.
* EmailContent content - the content of the email.
* BOOL isRead - marks if the email was or wasn't read. TRUE - read, FALSE - not read
* BOOL isMarked - marks if the email is marked as important. TRUE - marked, FALSE - not marked
*/
typedef struct 
{
    EmailID ID;
	EmailAddress recipient;
	EmailAddress sender;
	EmailDate date;
	EmailHour hour;
	EmailSubject subject;
	EmailContent content;
	BOOL isRead;
	BOOL isMarked;
} Email;

/*
* This struct represents a Request from the user. Operation must be provided.
* EmailID ID is only relevant to MARK_AS_READ, MARK_IMPORTANT_EMAIL, UNMARK_IMPORTANT_EMAIL, DELETE_EMAIL
* Email * email is only relevant to CREATE_EMAIL
* char * search_phrase is only relevant to GET_EMAILS_BY_WORD_SEARCH
*/
typedef struct
{
	Operation operation;
	EmailID ID;
	Email * email;
	char * search_phrase;
} Request;

#endif // HW1_TYPES_H
